package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.orderB.entity.Bill;
import com.egao.orderB.entity.BillExamine;
import com.egao.orderB.service.BillExamineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 *
 * 运单审核记录
 * @author : Doman
 * @date : 2021-04-13 10:40:47
 * @version ：1.0
 */

@Api(tags = "运单审核记录")
@RestController
@RequestMapping("/api/orderB/billExamine")
public class BillExamineController extends BaseController {

	@Autowired
	private BillExamineService billExamineService;

	/**
	 * 分页查询列表
	 */
	@PreAuthorize("hasAuthority('orderB:billExamine:list')")
    //@OperLog(value = "运单审核记录", desc = "分页查询")
    @ApiOperation(value ="分页查询运单审核记录",notes = "" +
        "limit:每页显示几行 必填\n" +
        "page:第几页 必填\n" +
        "billId: bill id 必填\n" +
        " \n\n\n" +
        "返回的结果:\n" +
       "id:id\n" +
       "billId:bill id\n" +
       "oceanid:海运Id\n" +
       "customerId:客户Id\n" +
       "customer:客户名称\n" +
       "contacts:联系人\n" +
       "contactsPhone:联系电话\n" +
       "state:状态\n" +
       "dock:口岸\n" +
       "province:模糊地址\n" +
       "address:详细地址\n" +
       "weight:箱门重量\n" +
       "boxType:箱型\n" +
       "price:价格\n" +
       "packDate:装箱日期(客户要求的装箱时间)\n" +
       "vessel:船名\n" +
       "voyage:航次\n" +
       "barcodeEffectiveDate:条码有效时间\n" +
       "earliestArrivalPortDate:最早进港时间\n" +
       "arrivalPort:进港码头\n" +
       "billOfLading:提单号\n" +
       "factoryAddress:工厂地址\n" +
       "factoryPhone:装箱人电话\n" +
       "efFactoryAddress:电子围栏工厂地址\n" +
       "efYard:电子围栏堆场\n" +
       "efDock:电子围栏港口码头\n" +
       "qrCode:二维码\n" +
       "carTeamId:车队id\n" +
       "carTeam:车队\n" +
       "carNo:车牌\n" +
       "driver:司机\n" +
       "driverPhone:司机电话\n" +
       "driverFreight:运费\n" +
       "sysDriverFreight:系统司机运费\n" +
       "boxNum:箱号\n" +
       "boxNumPic:箱号图片\n" +
       "sealno:封号\n" +
       "sealnoPic:封号图片\n" +
       "preEntryPic:预录入照片\n" +
       "annex:附件\n" +
       "upYard:提箱堆场\n" +
       "backYard:还箱堆场\n" +
       "whiteCard:白卡号\n" +
       "sfile:文件名称\n" +
       "remark:客户备注\n" +
       "feeremark:费用驳回的备注\n" +
       "platRemark:平台备注\n" +
       "financeRemark:财务备注\n" +
       "feeStateS:收款状态:已收款,已实收\n" +
       "feeStateF:付款状态:已付款,已实付\n" +
       "feeTotalS:总应收\n" +
       "feeTotalF:总应付\n" +
       "salesmanid:业务员Id\n" +
       "salesman:业务员\n" +
       "operaterid:操作Id\n" +
       "operater:操作\n" +
       "createTime:创建时间\n" +
       "createUser:创建人\n" +
       "updateTime:更新时间\n" +
       "updateUser:更新人\n" +
        "",httpMethod = "POST")
    @ApiPageParam
    @PostMapping("/page")
    public JsonResult page(PageResult2<T> page, BillExamine billExamine) throws Exception{
        return billExamineService.list(page, billExamine, getLoginUser());
    }

    /**
     * 查询全部运单审核记录
     */
    @PreAuthorize("hasAuthority('orderB:billExamine:list')")
    //@OperLog(value = "运单审核记录", desc = "查询全部")
    @ApiOperation(value ="查询全部运单审核记录",notes = "" +
            "billId: bill id 必填\n" +
            "",httpMethod = "POST")
    @PostMapping("/list")
    public JsonResult list(BillExamine billExamine){
        return billExamineService.list(billExamine, getLoginUser());
    }

    /**
     * 根据id查询运单审核记录
     */
    @PreAuthorize("hasAuthority('orderB:billExamine:list')")
    //@OperLog(value = "运单审核记录", desc = "根据id查询")
    @ApiOperation("根据id查询运单审核记录")
    @PostMapping("/get")
    public JsonResult get(BillExamine billExamine) {
        return billExamineService.getById(billExamine);
		// 使用关联查询
        //PageParam<billExamine> pageParam = new PageParam<>();
		//pageParam.put("id", id);
        //List<billExamine> records = billExamineService.listAll(pageParam.getNoPageParam());
        //return JsonResult.ok().setData(pageParam.getOne(records));
    }


    /**
     * 添加运单审核记录
     */
    @PreAuthorize("hasAuthority('orderB:billExamine:save')")
    @OperLog(value = "运单审核记录", desc = "添加", param = false, result = true)
    @ApiOperation(value ="添加运单审核记录",notes = "" +
            "billId:bill id\n" +
           "oceanid:海运Id\n" +
           "customerId:客户Id\n" +
           "customer:客户名称\n" +
           "contacts:联系人\n" +
           "contactsPhone:联系电话\n" +
           "state:状态:已下单,已做单,已接单,已提箱,已到厂,已离厂,已进港,发起费用清单,司机费用已审核,货代费用已审核,所有费用已审核,结单\n" +
           "dock:口岸\n" +
           "province:模糊地址\n" +
           "address:详细地址\n" +
           "weight:箱门重量\n" +
           "boxType:箱型\n" +
           "price:价格\n" +
           "packDate:装箱日期(客户要求的装箱时间)\n" +
           "vessel:船名\n" +
           "voyage:航次\n" +
           "barcodeEffectiveDate:条码有效时间\n" +
           "earliestArrivalPortDate:最早进港时间\n" +
           "arrivalPort:进港码头\n" +
           "billOfLading:提单号\n" +
           "factoryAddress:工厂地址\n" +
           "factoryPhone:装箱人电话\n" +
           "efFactoryAddress:电子围栏工厂地址\n" +
           "efYard:电子围栏堆场\n" +
           "efDock:电子围栏港口码头\n" +
           "qrCode:二维码\n" +
           "carTeamId:车队id\n" +
           "carTeam:车队\n" +
           "carNo:车牌\n" +
           "driver:司机\n" +
           "driverPhone:司机电话\n" +
           "driverFreight:运费\n" +
           "sysDriverFreight:系统司机运费\n" +
           "boxNum:箱号\n" +
           "boxNumPic:箱号图片\n" +
           "sealno:封号\n" +
           "sealnoPic:封号图片\n" +
           "preEntryPic:预录入照片\n" +
           "annex:附件\n" +
           "upYard:提箱堆场\n" +
           "backYard:还箱堆场\n" +
           "whiteCard:白卡号\n" +
           "sfile:文件名称\n" +
           "remark:客户备注\n" +
           "feeremark:费用驳回的备注\n" +
           "platRemark:平台备注\n" +
           "financeRemark:财务备注\n" +
           "feeStateS:收款状态:已收款,已实收\n" +
           "feeStateF:付款状态:已付款,已实付\n" +
           "feeTotalS:总应收\n" +
           "feeTotalF:总应付\n" +
           "salesmanid:业务员Id\n" +
           "salesman:业务员\n" +
           "operaterid:操作Id\n" +
           "operater:操作\n" +
        "",httpMethod = "POST")
    @PostMapping("/save")
    public JsonResult save(Model model, BillExamine billExamine) {
        return billExamineService.save(billExamine, getLoginUser());
    }

    /**
     * 添加运单审核记录
     */
    @PreAuthorize("hasAuthority('orderB:billExamine:save')")
    @OperLog(value = "运单审核记录", desc = "添加", param = false, result = true)
    @ApiOperation(value ="添加运单审核记录",notes = "" +
            "billId:bill id\n" +
           "oceanid:海运Id\n" +
           "customerId:客户Id\n" +
           "customer:客户名称\n" +
           "contacts:联系人\n" +
           "contactsPhone:联系电话\n" +
           "state:状态:已下单,已做单,已接单,已提箱,已到厂,已离厂,已进港,发起费用清单,司机费用已审核,货代费用已审核,所有费用已审核,结单\n" +
           "dock:口岸\n" +
           "province:模糊地址\n" +
           "address:详细地址\n" +
           "weight:箱门重量\n" +
           "boxType:箱型\n" +
           "price:价格\n" +
           "packDate:装箱日期(客户要求的装箱时间)\n" +
           "vessel:船名\n" +
           "voyage:航次\n" +
           "barcodeEffectiveDate:条码有效时间\n" +
           "earliestArrivalPortDate:最早进港时间\n" +
           "arrivalPort:进港码头\n" +
           "billOfLading:提单号\n" +
           "factoryAddress:工厂地址\n" +
           "factoryPhone:装箱人电话\n" +
           "efFactoryAddress:电子围栏工厂地址\n" +
           "efYard:电子围栏堆场\n" +
           "efDock:电子围栏港口码头\n" +
           "qrCode:二维码\n" +
           "carTeamId:车队id\n" +
           "carTeam:车队\n" +
           "carNo:车牌\n" +
           "driver:司机\n" +
           "driverPhone:司机电话\n" +
           "driverFreight:运费\n" +
           "sysDriverFreight:系统司机运费\n" +
           "boxNum:箱号\n" +
           "boxNumPic:箱号图片\n" +
           "sealno:封号\n" +
           "sealnoPic:封号图片\n" +
           "preEntryPic:预录入照片\n" +
           "annex:附件\n" +
           "upYard:提箱堆场\n" +
           "backYard:还箱堆场\n" +
           "whiteCard:白卡号\n" +
           "sfile:文件名称\n" +
           "remark:客户备注\n" +
           "feeremark:费用驳回的备注\n" +
           "platRemark:平台备注\n" +
           "financeRemark:财务备注\n" +
           "feeStateS:收款状态:已收款,已实收\n" +
           "feeStateF:付款状态:已付款,已实付\n" +
           "feeTotalS:总应收\n" +
           "feeTotalF:总应付\n" +
           "salesmanid:业务员Id\n" +
           "salesman:业务员\n" +
           "operaterid:操作Id\n" +
           "operater:操作\n" +
        "",httpMethod = "POST")
    @PostMapping("/saveBillExamine")
    public JsonResult save(Model model, Bill bill) {
        return billExamineService.save(bill, getLoginUser());
    }

    /**
     * 修改运单审核记录
     */
    @PreAuthorize("hasAuthority('orderB:billExamine:update')")
    @OperLog(value = "运单审核记录", desc = "修改", param = false, result = true)
    @ApiOperation(value ="修改运单审核记录",notes = "" +
           "id:id\n" +
            "billId:bill id\n" +
           "oceanid:海运Id\n" +
           "customerId:客户Id\n" +
           "customer:客户名称\n" +
           "contacts:联系人\n" +
           "contactsPhone:联系电话\n" +
           "state:状态:已下单,已做单,已接单,已提箱,已到厂,已离厂,已进港,发起费用清单,司机费用已审核,货代费用已审核,所有费用已审核,结单\n" +
           "dock:口岸\n" +
           "province:模糊地址\n" +
           "address:详细地址\n" +
           "weight:箱门重量\n" +
           "boxType:箱型\n" +
           "price:价格\n" +
           "packDate:装箱日期(客户要求的装箱时间)\n" +
           "vessel:船名\n" +
           "voyage:航次\n" +
           "barcodeEffectiveDate:条码有效时间\n" +
           "earliestArrivalPortDate:最早进港时间\n" +
           "arrivalPort:进港码头\n" +
           "billOfLading:提单号\n" +
           "factoryAddress:工厂地址\n" +
           "factoryPhone:装箱人电话\n" +
           "efFactoryAddress:电子围栏工厂地址\n" +
           "efYard:电子围栏堆场\n" +
           "efDock:电子围栏港口码头\n" +
           "qrCode:二维码\n" +
           "carTeamId:车队id\n" +
           "carTeam:车队\n" +
           "carNo:车牌\n" +
           "driver:司机\n" +
           "driverPhone:司机电话\n" +
           "driverFreight:运费\n" +
           "sysDriverFreight:系统司机运费\n" +
           "boxNum:箱号\n" +
           "boxNumPic:箱号图片\n" +
           "sealno:封号\n" +
           "sealnoPic:封号图片\n" +
           "preEntryPic:预录入照片\n" +
           "annex:附件\n" +
           "upYard:提箱堆场\n" +
           "backYard:还箱堆场\n" +
           "whiteCard:白卡号\n" +
           "sfile:文件名称\n" +
           "remark:客户备注\n" +
           "feeremark:费用驳回的备注\n" +
           "platRemark:平台备注\n" +
           "financeRemark:财务备注\n" +
           "feeStateS:收款状态:已收款,已实收\n" +
           "feeStateF:付款状态:已付款,已实付\n" +
           "feeTotalS:总应收\n" +
           "feeTotalF:总应付\n" +
           "salesmanid:业务员Id\n" +
           "salesman:业务员\n" +
           "operaterid:操作Id\n" +
           "operater:操作\n" +
        "",httpMethod = "POST")
    @PostMapping("/update")
    public JsonResult update(Model model, BillExamine billExamine) {
        return billExamineService.update(billExamine, getLoginUser());
    }

    /**
     * 删除运单审核记录
     */
    @PreAuthorize("hasAuthority('orderB:billExamine:remove')")
    @OperLog(value = "运单审核记录", desc = "删除", result = true)
    @ApiOperation("删除运单审核记录")
    @PostMapping("/remove")
    public JsonResult remove(BillExamine billExamine ) {
        return billExamineService.remove(billExamine, getLoginUser());
    }

    /**
     * 批量添加运单审核记录
     */
    /**@RequiresPermissions("orderB:billExamine:save")
    @OperLog(value = "运单审核记录", desc = "批量添加", param = false, result = true)
    @ResponseBody
    @PostMapping("/saveBatch")
    public JsonResult saveBatch(@RequestBody List<BillExamine> list) {
        if (billExamineService.saveBatch(list)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }*/

    /**
     * 批量修改运单审核记录
     */
    /**@RequiresPermissions("orderB:billExamine:update")
    @OperLog(value = "运单审核记录", desc = "批量修改", result = true)
    @ResponseBody
    @PostMapping("/updateBatch")
    public JsonResult updateBatch(@RequestBody BatchParam<BillExamine> batchParam) {
        if (batchParam.update(billExamineService, "")) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }*/

    /**
     * 批量删除运单审核记录
     */
    /**@RequiresPermissions("orderB:billExamine:remove")
    @OperLog(value = "运单审核记录", desc = "批量删除", result = true)
    @ResponseBody
    @PostMapping("/removeBatch")
    public JsonResult removeBatch(@RequestBody List<Integer> ids) {
        if (billExamineService.removeByIds(ids)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }*/

}
